
/**build:  
clang++  user_main.cpp -o user_main.app &&  ./user_main.app
or
clang -lstdc++  user_main.cpp -o user_main.app &&  ./user_main.app 
*/#include <string.h>#include "User.h"

#include <iostream>

int User::NextUserId=FIRST_USER_ID;
User* User::Table[MAX_USER_ID+1];

void User::printTable(){
	for(int userIdK=0; userIdK <= MAX_USER_ID; userIdK++){
		User* userK=User::Table[userIdK];
		if(userK==NULL){
			std::cout<< userIdK << ":empty"  <<  std::endl;
		}else{
			std::cout<< userIdK << ":" << userK->userId << ":" << userK->userName << "," << userK->password << std::endl;
		}

	}
}
	User* User::find(char* userName){	for(int userIdK=0; userIdK <= MAX_USER_ID; userIdK++){		User* userK=User::Table[userIdK];		if(userK==NULL){			continue;		}				if(strcmp(userK->getUserName(),userName)==0){			return userK;		}	}	return NULL;}User* User::reg(char* userName,char* password){	int userId;	if(strcmp(userName,ADMIN_USER_NAME)==0){		userId=ADMIN_USER_ID;	}else{		userId=User::genNextUserId();	}	if(userId <= MAX_USER_ID){		User* userPtr=new User(userId,userName,password);		User::Table[userId]=userPtr;		return userPtr;	}else{		return NULL;	}}int main(int argc,char** argv){	User* zhangsanUserPtr=User::reg("zhangsan","nopass");	User* lisiUserPtr=User::reg("lisi","mypass");	User* wamgwuUserPtr=User::reg("wangwu","pass123");	User* userX=User::find("zhangsan");
	User::printTable();	return 0;}